class_name HurtBox extends Area2D

# 定义一个信号 受伤时发出
signal hurt(hitbox : HitBox)

func _ready() -> void:
	area_entered.connect(_on_area_entered)

func _on_area_entered(area2d:Area2D) -> void:
	#如果不是攻击框就直接返回
	if area2d is not HitBox: return
	var hitbox = area2d as HitBox
	if self in hitbox.hit_targets: 
		print("已经攻击过了")
		return
	if hitbox.stores_hit_targets: hitbox.hit_targets.append(self)
	#发送信号
	hurt.emit(area2d)
